<!doctype html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml" xmlns:v-on="http://www.w3.org/1999/xhtml" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<div id="app">
    <p>插值直接使用过滤器：{{msg | capitalize}}</p>
    <div v-bind:id="id | formatId">bind过滤器：{{id | formatId}}</div>
    <div>多个过滤器：{{msg | first | middle | last}}</div>
    <div>过滤器传参：{{list | gt(3,8)}}</div>
</div>
</body>
<script src="../../vender/vue@2.4.2.js"></script>
<script>

    var vm=new Vue({
        el:'#app',
        data:{
            msg:'Hello Vue',
            id:'test id',
            list:[2,4,6,8,10]
        },
        filters:{
            capitalize:function(val){
                return val.toUpperCase();
            },
            formatId: function (val) {
                return val.replace(/\s+/,'-');
            },
            first: function (val) {
                return val[0].toUpperCase()+val.slice(1);
            },
            middle: function (val) {
                return val.replace(/\s+/,'-');
            },
            last: function (val) {
                return val.slice(0,-1)+val[val.length-1].toUpperCase();
            },
            gt: function (list,min=Infinity,max=-Infinity) {
                return list.filter(item=>item>min&&item<max);
            }
        }
    });

</script>
</html>